package com.eurasia.assignment.infrastructure.entity;

import java.time.LocalDateTime;

import com.eurasia.assignment.domain.Project;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "projects")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ProjectEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    private String name;
    private String course;
    private String type;
    private LocalDateTime createTime;
    private String finishTime;
    private String status;
    private String score;
    private Integer points;

    public static ProjectEntity fromDomain(Project project) {
        ProjectEntity entity = new ProjectEntity();
        entity.setId(project.getId());
        entity.setName(project.getName());
        entity.setCourse(project.getCourse());
        entity.setType(project.getType());
        entity.setCreateTime(project.getCreateTime());
        entity.setFinishTime(project.getFinishTime());
        entity.setStatus(project.getStatus());
        entity.setScore(project.getScore());
        entity.setPoints(project.getPoints());
        return entity;
    }

    public Project toDomain() {
        return new Project(id, name, course, type, createTime, finishTime, status, score, points);
    }
} 